/**
 * @param {Array} menulist 用户的菜单信息，用于和allRoutes进行对比
 * @param {Array} allRoutes 用户的完成动态路由表
 */

let recursionRoutes = (menulist = [],allRoutes=[])=>{
    //用于放置对比之后的路由数据
    let userRoutes = []
    menulist.length > 0 && menulist.forEach(menu => {
        //一个menu长这样
        //{id:'1',title:'glsy',name:'管理首页'}
        allRoutes.forEach(route =>{
            if(menu.title === route.meta.title){
                if(menu.children && menu.children.length >0){
                    //如果有children属性，需要递归重新计算
                    route.children = recursionRoutes(menu.children,route.children)
                }
                userRoutes.push(route)
            }
        })
    })
    return userRoutes
}
export default recursionRoutes